From: Carlos Garnacho Date: Wed, 8 Oct 2025 17:11:37 +0000 (+0200) Subject: panel: Use click gesture to trigger window dragging from panel X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~39^2~1^2~53 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0a2da9d412769938017b0d24643ef044acdeb13f;p=gnome-shell.git panel: Use click gesture to trigger window dragging from panel This gesture is set up on the target phase, in order to ensure only button presses on the panel itself (and not actors within it) are handled as window drags. Part-of: --- diff --git a/js/ui/panel.js b/js/ui/panel.js index 5f5a3c5d8..d836107a8 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -451,8 +451,13 @@ class Panel extends St.Widget { this._rightBox = new St.BoxLayout({name: 'panelRight'}); this.add_child(this._rightBox); - this.connect('button-press-event', this._onButtonPress.bind(this)); - this.connect('touch-event', this._onTouchEvent.bind(this)); + this._clickGesture = new Clutter.ClickGesture({ + recognize_on_press: true, + }); + this._clickGesture.connect( + 'recognize', this._onWindowDragGestureRecognize.bind(this)); + this.add_action_full( + 'window-drag', Clutter.EventPhase.TARGET, this._clickGesture); Main.overview.connectObject('showing', () => this.add_style_pseudo_class('overview'), @@ -542,43 +547,25 @@ class Panel extends St.Widget { this._rightBox.allocate(childBox); } - _tryDragWindow(event) { + _onWindowDragGestureRecognize() { if (Main.modalCount > 0) - return Clutter.EVENT_PROPAGATE; + return; + const event = this._clickGesture.get_point_event(0); const backend = global.stage.get_context().get_backend(); const sprite = backend.get_sprite(global.stage, event); - const targetActor = global.stage.get_event_actor(event); - if (targetActor !== this) - return Clutter.EVENT_PROPAGATE; - - const [x, y] = event.get_coords(); - const dragWindow = this._getDraggableWindowForPosition(x); + const coords = this._clickGesture.get_coords_abs(); + const dragWindow = this._getDraggableWindowForPosition(coords.x); if (!dragWindow) - return Clutter.EVENT_PROPAGATE; + return; - const positionHint = new Graphene.Point({x, y}); - return dragWindow.begin_grab_op( + dragWindow.begin_grab_op( Meta.GrabOp.MOVING, sprite, event.get_time(), - positionHint) ? Clutter.EVENT_STOP : Clutter.EVENT_PROPAGATE; - } - - _onButtonPress(actor, event) { - if (event.get_button() !== Clutter.BUTTON_PRIMARY) - return Clutter.EVENT_PROPAGATE; - - return this._tryDragWindow(event); - } - - _onTouchEvent(actor, event) { - if (event.type() !== Clutter.EventType.TOUCH_BEGIN) - return Clutter.EVENT_PROPAGATE; - - return this._tryDragWindow(event); + coords); } vfunc_key_press_event(event) {